package comp211.calendar.apptstorage;

import java.util.Vector;

import comp211.calendar.unit.Appt;
import comp211.calendar.unit.TimeSpan;
import comp211.calendar.unit.User;

public class ApptStorageControllerImpl {

	public final static int REMOVE = 1;

	public final static int MODIFY = 2;

	public final static int NEW = 3;

	private ApptStorage mApptStorage;

	public ApptStorageControllerImpl(ApptStorage storage) {
		mApptStorage = storage;
	}

	public Appt[] RetrieveAppts(User entity, TimeSpan time) {
		return mApptStorage.RetrieveAppts(entity, time);
	}

	public void ManageAppt(Appt appt, int action) {

		if (action == NEW) {
			if (appt == null)
				return;
			mApptStorage.SaveAppt(appt);
		} else if (action == MODIFY) {
			if (appt == null)
				return;
			mApptStorage.UpdateAppt(appt);
		} else if (action == REMOVE) {
			mApptStorage.RemoveAppt(appt);
		}

	}

	public User getDefaultUser() {
		return mApptStorage.getDefaultUser();
	}

}
